﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OmegleStormer
{
    public partial class Stats : UserControl
    {
        public class Statistics
        {
            public int AdsPerformed { get; set; }
            public int AdsPossiblyPerformed { get; set; }
            public int AdsPerMinute { get; set; }
            public int AdsFailed { get; set; }
            public int CaptchasPerformed { get; set; }
            public int CaptchasFailed { get; set; }
            public int ThreadsRunning { get; set; }
            public int ConvoStartFailed { get; set; }
            public int DecaptchaServiceErrors { get; set; }
            public int ConnectionErrors { get; set; }
            public int ReplyTimedOuts { get; set; }
            public int TimeoutErrors { get; set; }
            public int StrangerDisconnects { get; set; }
            public int InstantDisconnects { get; set; }
            public decimal MegaBytesUsed { get; set; }
        }

        public Statistics StatsLive { get; set; }

        public Stats()
        {
            StatsLive = new Statistics();
            InitializeComponent();
            Timer updateTimer = new Timer();
            updateTimer.Interval = 350;
            updateTimer.Tick += new EventHandler(updateTimer_Tick);
            updateTimer.Start();
        }

        void updateTimer_Tick(object sender, EventArgs e)
        {
            var stats = new string[] { 
                "Threads Running:" + StatsLive.ThreadsRunning,
                "MegaBytes Used:" + StatsLive.MegaBytesUsed,
                "Ads Performed:" +  StatsLive.AdsPerformed,
                "Ads Probably Performed:" + StatsLive.AdsPossiblyPerformed,
                "Ads Per Minute:" + StatsLive.AdsPerMinute,
                "Ads Failed:" +  StatsLive.AdsFailed,
                "Captchas Performed:" +  StatsLive.CaptchasPerformed,
                "Captchas Failed:" +  StatsLive.CaptchasFailed,
                "Decaptcha Service Errors:" + StatsLive.DecaptchaServiceErrors,
                "ConvoStart Fails:" + StatsLive.ConvoStartFailed,
                "Connection Errors:" + StatsLive.ConnectionErrors,
                "Reply Timed Outs:" + StatsLive.ReplyTimedOuts,
                "Timeout Errors:" + StatsLive.TimeoutErrors,
                "Stranger Disconnects:" + StatsLive.StrangerDisconnects,
                "Instant Disconnects:" + StatsLive.InstantDisconnects,
            };

            string[] leftLabel = new string[stats.Length];
            string[] rightLabel = new string[stats.Length];
            for (int i = 0; i < stats.Length; i++)
            {
                var parts = stats[i].Split(':');
                leftLabel[i] = parts[1];
                rightLabel[i] = parts[0];
            }
            label1.Text = string.Join(Environment.NewLine, leftLabel);
            label2.Text = string.Join(Environment.NewLine, rightLabel);

        }
    }
}
